local ClientOHOH = _G.ClientOHOH;
local M = ClientOHOH.class.new(script, ClientOHOH.files.Client_PlayerComponent(),script.Parent.Name);
local ReadyGui = _G.ClientOHOH.load.UIManager():CreateUI("ReadyGui",require(script.ReadyGui))
local Countdown = game.ReplicatedStorage:WaitForChild("ReadyTimer")
local game_cfg=_G.CommonOHOH.config.Game
local gWait2startGame=game_cfg.wait2startGame
function M.new(self,...)
	return M(self,...);
end;


function M.ctor(self, parent)
    M.super.ctor(self, parent);
    self.player=self.parent
    self:AddConnect()
end

function M.AddConnect(self)
    self.player.main_inst.CharacterAdded:Connect(function()
        if  workspace:GetAttribute("GameState")==0 then
            ReadyGui:Show()
            self:Countdown()
        end
    end)
    --游戏准备倒计时
	_G.client.GameStateChangeEvent:Connect(function(state)
        if state==0 then
            ReadyGui:Show()
            self:Countdown()
        end
        if state~=0 then
            ReadyGui:Hide()
        end
    end)
end

function M.Countdown(self)
    local waitTime = gWait2startGame- (os.time() - workspace:GetAttribute("StateTime"))
    self:AddProcess(function()
        for time = waitTime,1,-1 do
            ReadyGui:SetText(time)
            wait(1)
        end
    end)
end

function M.dtor(self)
	M.super.dtor(self);
end;

return M